package test.db.table.mysql.type;

import test.db.table.Table;
import test.db.util.DBUtil;

/**
 * @author newbie
 * @since 0.1
 */
public enum PwBbsEnvTable implements Table {
    BAD_IP(Column.badIp),
    BAD_ID(Column.badId),
    BAD_NICK(Column.badNick),
    BAD_CONTENT(Column.badContent),
    WRITE_PERMIT(Column.writePermit),
    WRITE_PER_DAY(Column.writePerDay),
    INPUT_LIMIT_IP(Column.inputLimitIp),
    INPUT_LIMIT_ID(Column.inputLimitId),
    PROTECT_REPLY_CNT(Column.protectReplyCnt),
    PROTECT_MEMO_CNT(Column.protectMemoCnt),
    LOGIN_POINT(Column.loginPoint),
    WRITE_POINT(Column.writePoint),
    REPLY_POINT(Column.replyPoint),
    MEMO_POINT(Column.memoPoint),
    RATE_POINT(Column.ratePoint),
    BEST_POINT(Column.bestPoint),
    TAG_POINT(Column.tagPoint),
    STAR_POINT(Column.starPoint),
    POLL_POINT(Column.pollPoint),
    DEL_POINT(Column.delPoint),
    COMMON_SKIN(Column.commonSkin),
    TRY_LOGIN(Column.tryLogin),
    EMAIL_SMTP(Column.emailSmtp),
    EMAIL_ACCOUNT(Column.emailAccount),
    EMAIL_PASSWORD(Column.emailPassword),
    CERTIFY_SENDER(Column.certifySender),
    CERTIFY_TITLE(Column.certifyTitle),
    CERTIFY_CONTENT(Column.certifyContent),
    BASIC_AUTH(Column.basicAuth),
    AUTO_CERTIFY_YN(Column.autoCertifyYn);

    private final Column column;
    private static final String TYPE_BAD_IP = "TEXT";
    private static final String TYPE_BAD_ID = "TEXT";
    private static final String TYPE_BAD_NICK = "TEXT";
    private static final String TYPE_BAD_CONTENT = "TEXT";
    private static final String TYPE_WRITE_PERMIT = "INT(8)";
    private static final String TYPE_WRITE_PER_DAY = "INT(8)";
    private static final String TYPE_INPUT_LIMIT_IP = "TEXT";
    private static final String TYPE_INPUT_LIMIT_ID = "TEXT";
    private static final String TYPE_PROTECT_REPLY_CNT = "INT(8)";
    private static final String TYPE_PROTECT_MEMO_CNT = "INT(8)";
    private static final String TYPE_LOGIN_POINT = "INT(8)";
    private static final String TYPE_WRITE_POINT = "INT(8)";
    private static final String TYPE_REPLY_POINT = "INT(8)";
    private static final String TYPE_MEMO_POINT = "INT(8)";
    private static final String TYPE_RATE_POINT = "INT(8)";
    private static final String TYPE_BEST_POINT = "INT(8)";
    private static final String TYPE_TAG_POINT = "INT(8)";
    private static final String TYPE_STAR_POINT = "INT(8)";
    private static final String TYPE_POLL_POINT = "INT(8)";
    private static final String TYPE_DEL_POINT = "INT(8)";
    private static final String TYPE_COMMON_SKIN = "VARCHAR(255)";
    private static final String TYPE_TRY_LOGIN = "INT(3)";
    private static final String TYPE_EMAIL_SMTP = "VARCHAR(255)";
    private static final String TYPE_EMAIL_ACCOUNT = "VARCHAR(255)";
    private static final String TYPE_EMAIL_PASSWORD = "VARCHAR(255)";
    private static final String TYPE_CERTIFY_SENDER = "VARCHAR(255)";
    private static final String TYPE_CERTIFY_TITLE = "VARCHAR(255)";
    private static final String TYPE_CERTIFY_CONTENT = "TEXT";
    private static final String TYPE_BASIC_AUTH = "VARCHAR(12)";
    private static final String TYPE_AUTO_CERTIFY_YN = "CHAR(1)";
    
    PwBbsEnvTable(Column column) {
        this.column = column;
    }
    
    private enum Column {
        badIp {
            String getType() {
                return TYPE_BAD_IP;
            }
        },
        
        badId {
            String getType() {
                return TYPE_BAD_ID;
            }
        },
        
        badNick {
            String getType() {
                return TYPE_BAD_NICK;
            }
        },
        
        badContent {
            String getType() {
                return TYPE_BAD_CONTENT;
            }
        },
        
        writePermit {
            String getType() {
                return TYPE_WRITE_PERMIT;
            }
        },
        
        writePerDay {
            String getType() {
                return TYPE_WRITE_PER_DAY;
            }
        },
        
        inputLimitIp {
            String getType() {
                return TYPE_INPUT_LIMIT_IP;
            }
        },
        
        inputLimitId {
            String getType() {
                return TYPE_INPUT_LIMIT_ID;
            }
        },
        
        protectReplyCnt {
            String getType() {
                return TYPE_PROTECT_REPLY_CNT;
            }
        },
        
        protectMemoCnt {
            String getType() {
                return TYPE_PROTECT_MEMO_CNT;
            }
        },
        
        loginPoint {
            String getType() {
                return TYPE_LOGIN_POINT;
            }
        },
        
        writePoint {
            String getType() {
                return TYPE_WRITE_POINT;
            }
        },
        
        replyPoint {
            String getType() {
                return TYPE_REPLY_POINT;
            }
        },
        
        memoPoint {
            String getType() {
                return TYPE_MEMO_POINT;
            }
        },
        
        ratePoint {
            String getType() {
                return TYPE_RATE_POINT;
            }
        },
        
        bestPoint {
            String getType() {
                return TYPE_BEST_POINT;
            }
        },
        
        tagPoint {
            String getType() {
                return TYPE_TAG_POINT;
            }
        },
        
        starPoint {
            String getType() {
                return TYPE_STAR_POINT;
            }
        },
        
        pollPoint {
            String getType() {
                return TYPE_POLL_POINT;
            }
        },
        
        delPoint {
            String getType() {
                return TYPE_DEL_POINT;
            }
        },
        
        commonSkin {
            String getType() {
                return TYPE_COMMON_SKIN;
            }
        },
        
        tryLogin {
            String getType() {
                return TYPE_TRY_LOGIN;
            }
        },
        
        emailSmtp {
            String getType() {
                return TYPE_EMAIL_SMTP;
            }
        },
        
        emailAccount {
            String getType() {
                return TYPE_EMAIL_ACCOUNT;
            }
        },
        
        emailPassword {
            String getType() {
                return TYPE_EMAIL_PASSWORD;
            }
        },
        
        certifySender {
            String getType() {
                return TYPE_CERTIFY_SENDER;
            }
        },
        
        certifyTitle {
            String getType() {
                return TYPE_CERTIFY_TITLE;
            }
        },
        
        certifyContent {
            String getType() {
                return TYPE_CERTIFY_CONTENT;
            }
        },
        
        basicAuth {
            String getType() {
                return TYPE_BASIC_AUTH;
            }
        },
        
        autoCertifyYn {
            String getType() {
                return TYPE_AUTO_CERTIFY_YN;
            }
        };
        
        abstract String getType();        
    }
    
    /* (non-Javadoc)
     * @see test.db.table.Table#getType()
     */
    public String getType() {
        return column.getType();
    }

    /* (non-Javadoc)
     * @see test.db.table.Table#initData()
     */
    public void initData() throws Exception {
        DBUtil.addData("INSERT INTO PW_BBS_ENV (COMMON_SKIN) VALUES ('default')");
    }
}